<template>
	<view class="pd16_15">
		<view class="box pd16_15 mb16" v-if="mendiandatatype==1" v-for="(item,index) in addrs" :key="index" @click="edit(item)">
			<view class="flex alcenter space">
				<text class="ft16 ftw600 cl-main">{{item.mname}}</text>
				<text v-if="item.type==1" class="ft16 ftw600 cl-main coupon-tip">审核中</text>
				<text v-if="item.type==2" class="ft16 ftw600 cl-main coupon-tip">已审核</text>
				<text v-if="item.type==3" class="ft16 ftw600 cl-main coupon-tip">驳回</text>
			</view>
			<view class="mt16 flex alcenter space">
				<view class="flex cl-notice" style="width: calc(100% - 80rpx);">
					<text class="iconfont iconicon_location01 ft12" style="line-height: 36rpx;"></text>
					<view class="ml5 ft12" style="width: calc(100% - 40rpx); line-height: 36rpx;">
						{{item.province}} {{item.city}} {{item.district}} {{item.address}}
					</view>
				</view>
				<text class="iconfont iconbtn_edit_linear ft20 cl-blue"></text>
			</view>
			<view class="mt5 flex alcenter space"  v-if="item.type==3">
				<view  class="flex cl-notice" style="width: calc(100% - 80rpx);">
					<view class="ml5 ft12" style="width: calc(100% - 40rpx); line-height: 36rpx; color: #ff0000;">
						驳回理由：{{item.bz}}
					</view>
				</view>
			</view>
			<view class="bd-line mt16 mb16"></view>
			<view class="mt16 flex alcenter space">
				<view class="flex cl-notice" style="width: calc(100% - 80rpx);">
					<view class="ml5 ft12" style="width: calc(100% - 40rpx); line-height: 36rpx;">
						<text class="ft12 cl-main mr15 cl-notice">{{item.name}}</text>
						<text class="iconfont iconicon_bottom_call ft12" style="line-height: 36rpx;"></text>
						{{item.tel}}
					</view>
				</view>
			</view>			
		</view>
		<view v-if="mendiandatatype==2" class="box pd24_15">
			<view class="text-center ft14 cl-info2">您还没有门店，申请后即可赚取佣金</view>
			<view class="flex center mt24">
				<button class="btn-mid" @click="mendianadd" :style="getBtnStyle">立即申请</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				mendiandata:[],
				mendiandatatype:1,
				addrs:[],
				listData: [],
				last_id: 0,
				reload: true,
				status: 'more',
				statusa: false,
				text:'',
				contentText: {
					contentdown: '上拉加载更多',
					contentrefresh: '加载中',
					contentnomore: '没有数据了'
				}
			}
		},
		onLoad(e){
			uni.getLocation({
			    type: 'wgs84',
				geocode:true,
			    success: function (res) {
					console.log('当前位置：' + res.address);
			        console.log('当前位置的经度：' + res.longitude);
			        console.log('当前位置的纬度：' + res.latitude);
			    }
			});
		},
		onShow() {
			this.last_id=0
			this.reload=true
			this.getList();
		},
		onReachBottom() {
			this.status = 'more';
			this.getList();
		},
		// 监听原生标题导航按钮点击事件
		onNavigationBarButtonTap(e) {
			const index = e.index;
				uni.navigateTo({
					url:"/pages/client/vipcard/adviser"
				})
				
		},
		methods:{
			getList() {
				let data = {
					//column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名
				};
				var limit=10;
				if (this.last_id>0) {
					//说明已有数据，目前处于上拉加载
					this.status = 'loading';
					data.offset = this.last_id*limit;
					data._ = new Date().getTime() + '';
				}
				
				if(this.text){
					data.text=this.text
				}
				data.limit=limit		
				data.token = uni.getStorageSync("userinfo").token;
				uni.request({
					url: this.configs.webUrl+'/api/user/mendianlist',
					data: data,
					success: data => {
						console.log(data.data)
						if (data.data.total>0) {
							this.mendiandatatype=1
							let list = data.data.rows;
							this.addrs = this.reload ? list : this.addrs.concat(list);
							this.reload = false;
							this.last_id = this.last_id+1;
							if(data.data.total<this.last_id*limit){
								this.status = '';
							}
						}else{
							this.mendiandatatype=2
							this.contentText.contentdown='没有数据'
						}
					},
					fail: (data, code) => {
						//console.log('fail' + JSON.stringify(data));
					}
				});
			},
			selectMendian(){
				uni.navigateBack({
					delta:1,
				})
			},
			mendianadd(){
				uni.navigateTo({
					url:'/pages/client/member/mendianadd'
				})
			},
			edit(item){
				uni.setStorage({//缓存配置信息
					key: 'MendianitemData',  
					data: item
				})
				uni.navigateTo({
					url:'/pages/client/member/mendianeditform'
				})
			},
		}
	}
</script>

<style>
	
</style>